<!-- 店铺详情 -->
<template>
	<div class="wrapper">
		<van-icon name="arrow-left" class="back-icon" @click="backPage" />
		<van-search v-model="searchVal" label="搜索" shape="round" input-align="center" placeholder="请输入搜索关键词" />
		<ShopInfo :item="item" v-if="item.imgUrl" />
		<Content />
		<Cart />
	</div>
</template>

<script>
import _axios from '@/api/axios.js';
import { ref, reactive, onMounted, toRefs } from 'vue';
import { useRouter, useRoute } from 'vue-router'
import ShopInfo from '@/components/ShopInfo'
import Content from './Content'
import Cart from './Cart'
export default {
	name: 'Shop',
	setup () {
		const router = useRouter();
		const route = useRoute();
		console.log(route.params.id); // 获取路由传参

		const data = reactive({ item: {} })
		const getShop = () => {
			_axios.get('api/getShop', { id: route.params.id }).then(res => {
				data.item = res.data;
			}).catch(err => {
				console.log(err);
			});
		};
		onMounted(() => {
			getShop();
		})

		const searchVal = ref('');

		const backPage = () => {
			router.back();
		}

		return {
			...toRefs(data),
			searchVal,
			backPage
		};
	},
	components: { ShopInfo, Content, Cart }
};
</script>

<style lang="scss" scoped>
.back-icon {
	position: absolute;
	top: 0;
	left: 0;
	font-size: 0.16rem;
	padding: 0.19rem 0.1rem;
}
.wrapper {
	padding: 0 0.18rem 0.18rem;
}
</style>
